package com.cym.utils;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cym.sqlHelper.utils.SqlHelper;

import cn.hutool.core.date.DateUtil;

/**
 * Author: D.Yang Email: koyangslash@gmail.com Date: 16/10/9 Time: 下午1:37
 * Describe: 基础控制器
 */
@Component
public class BaseController {
	@Autowired
	public SqlHelper sqlHelper;
	
	public JsonResult renderError() {
		JsonResult result = new JsonResult();
		result.setSuccess(false);
		result.setStatus("200");
		result.setTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		;
		return result;
	}

	public JsonResult renderError(String msg) {
		JsonResult result = renderError();
		result.setMsg(msg);
		return result;
	}

	public JsonResult renderSuccess() {
		JsonResult result = new JsonResult();
		result.setSuccess(true);
		result.setStatus("200");
		result.setTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		return result;
	}

	public JsonResult renderSuccess(Object obj) {
		JsonResult result = renderSuccess();
		result.setObj(obj);
		return result;
	}

}
